package com.my.vote.entity;

import android.text.TextUtils;

import com.my.vote.R;

import cn.bmob.v3.BmobObject;

/**
 * 功能描述:投票详情-[对于后台数据库表对象]
 *
 * @author Xiao Jingxiang 肖景翔
 * @date 2018/4/11
 */
public class EVoteInfo extends BmobObject  {

    /**
     * 发布者ID
     */
    String userId;

    String voteUrl;

    String title;

    /**
     * 介绍
     */
    String introduce;

    /**
     * 当前模式 1 可以参加报名模式， 2 只能投票模式
     */
    String type;

    /**
     * 投票模式 1 只能投票一个， 2 只能投票2个 依次类推
     */
    Integer voteType;
    /**
     * 投票结束时间
     */
    Double voteEndTime;

    /**
     * 报名结束时间
     */
    Double enrollEndTime;

    /**
     * 候选
     */
    Integer candidateSize;

    /**
     * 投票人次
     */
    Integer votingPersonSize;

    /**
     * 访问量
     */
    Integer visitSize;

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getVoteUrl() {
        return voteUrl;
    }

    public void setVoteUrl(String voteUrl) {
        this.voteUrl = voteUrl;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getIntroduce() {
        return introduce;
    }

    public void setIntroduce(String introduce) {
        this.introduce = introduce;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Integer getVoteType() {
        return voteType;
    }

    public void setVoteType(Integer voteType) {
        this.voteType = voteType;
    }

    public Double getVoteEndTime() {
        return voteEndTime;
    }

    public void setVoteEndTime(Double voteEndTime) {
        this.voteEndTime = voteEndTime;
    }

    public Double getEnrollEndTime() {
        return enrollEndTime;
    }

    public void setEnrollEndTime(Double enrollEndTime) {
        this.enrollEndTime = enrollEndTime;
    }

    public Integer getCandidateSize() {
        return candidateSize;
    }

    public void setCandidateSize(Integer candidateSize) {
        this.candidateSize = candidateSize;
    }

    public Integer getVotingPersonSize() {
        return votingPersonSize;
    }

    public void setVotingPersonSize(Integer votingPersonSize) {
        this.votingPersonSize = votingPersonSize;
    }

    public Integer getVisitSize() {
        return visitSize;
    }

    public void setVisitSize(Integer visitSize) {
        this.visitSize = visitSize;
    }

    /**
     * 当前状态 1 投票中， 2 报名中 3 投票结束
     */
    public String getStatue() {

        long sysTime = System.currentTimeMillis();

        //有报名时间
        if (this.enrollEndTime !=null && this.enrollEndTime - sysTime > 0) {
            // 状态-2 报名中
            return "2";
        } else if (this.voteEndTime  != null && this.voteEndTime - sysTime > 0) {
            // 状态-1 投票中
            return "1";
        } else {
            // 状态-3 投票结束
            return "3";
        }
    }

    public String getStatueText(String statue) {
        return TextUtils.equals("1", statue) ? "In The Vote" :
                TextUtils.equals("2", statue) ? "Enrolment" : "Vote End";
    }

    public int getStatueDrawable(String statue) {
        return TextUtils.equals("1", statue) ? R.drawable.file_vote_lable :
                TextUtils.equals("2", statue) ? R.drawable.file_vote_lable2 : R.drawable.file_vote_lable3;
    }

}
